//package com.hucheng.user.rabbitmq;
//
//import com.alibaba.fastjson.JSONObject;
//import com.hucheng.common.utils.ValidatorUtils;
//import com.hucheng.user.config.RabbitP2PConfig;
//import com.hucheng.user.entity.UserPointDO;
//import com.hucheng.user.entity.UserPointExpiredDetailsDO;
//import com.hucheng.user.service.UserPointService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//
///**
// * @Author: 凉白开不加冰
// * @Version: 0.0.1V
// * @Date: 2019-07-01
// * @Description: 秒杀商品队列消费
// **/
//@Slf4j
//@Component
//public class PointReceiver {
//
//    @Autowired
//    private UserPointService userPointService;
//
//    private ExecutorService service = Executors.newFixedThreadPool(10);
//
//    @RabbitListener(queues = RabbitP2PConfig.POINT_QUEUE_NAME)
//    public void receive(String msg) {
//        log.info("清除过期积分开始 >>>>>>>>> " + msg);
//        if (ValidatorUtils.isEmpty(msg) || msg.equals("[]")) {
//            return;
//        }
//
//        service.execute(() -> {
//
//            List<UserPointExpiredDetailsDO> lists = JSONObject.parseArray(msg, UserPointExpiredDetailsDO.class);
//
//            List<UserPointDO> pointDOList = new ArrayList<>();
//
//            lists.forEach(userPointExpiredDetailsDO -> {
//                //修改过期表过期积分状态
//                userPointExpiredDetailsDO.setPointType(2);
//
//                //修改用户过期积分
//                UserPointDO userPointDO = new UserPointDO();
//                userPointDO.setUserId(userPointExpiredDetailsDO.getUserId());
//                userPointDO.setPointExpired(userPointExpiredDetailsDO.getPoint());
//                userPointDO.setPoint(userPointExpiredDetailsDO.getPoint());
//                pointDOList.add(userPointDO);
//            });
//
//            userPointService.updateBatchPoint(pointDOList);
//            userPointService.updateBatchPointExpired(lists);
//            log.info("清除过期积分结束 >>>>>>>>> " + lists.size());
//        });
//
//    }
//}
